﻿Imports System.Reflection
Imports System.IO

Public Class DataMapper

    Public Function Map(ByVal objetToMap As Object, _
                         ByVal dt As Data.DataTable, _
                         ByVal dr As Data.DataRow, _
                         ByVal ignoreCollection() As String) As Object

        Try
            Dim dc As Data.DataColumn
            Dim propInfo As PropertyInfo

            For Each dc In dt.Columns

                propInfo = objetToMap.GetType.GetProperty(dc.ColumnName)

                If propInfo IsNot Nothing Then
                    If propInfo.Name.ToUpper = dc.ColumnName.ToUpper Then
                        propInfo.SetValue(objetToMap, dr.Item(dc.ColumnName), Nothing)
                    End If
                End If
            Next

            Return objetToMap
        Catch ex As Exception
            Throw New Exception("", ex)
        End Try

    End Function

End Class
